package m.jclecai.com.fragment.follow;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import m.jclecai.com.R;
import m.jclecai.com.base.BaseFragment;
import m.jclecai.com.fragment.refreshableList.MineOrderListFragment;
import m.jclecai.com.fragment.refreshableList.OrderMineListFragment;
import m.jclecai.com.view.common.RectangleTabLayout;

/**
 * Created by Dinosa on 2017/11/20.
 * 定制跟单:分为我的定制和定制我的两种；
 */
public class CustomOrderFragment extends BaseFragment {

    @BindView(R.id.rtl_indicator)
    RectangleTabLayout mRtlIndicator;

    @BindView(R.id.vp_view_pager)
    ViewPager mVpViewPager;


    private CharSequence[] mStrings = {"我的定制", "定制我的"};
    private List<BaseFragment> mCustomOrders;


    @Override
    public int getLayoutId() {
        return R.layout.fragment_mine_custom_order;
    }

    @Override
    public void initData() {


        initFragments();

        mVpViewPager.setAdapter(new MyPagerAdapter(getChildFragmentManager()));
        mRtlIndicator.setupWithViewPager(mVpViewPager);

    }

    /**
     * 这里初始化页面；
     */
    private void initFragments() {
        mCustomOrders=new ArrayList<>();
        mCustomOrders.add(new MineOrderListFragment());
        mCustomOrders.add(new OrderMineListFragment());
    }


    public class MyPagerAdapter extends FragmentPagerAdapter {

        @Override
        public CharSequence getPageTitle(int position) {
            return mStrings[position];
        }

        public MyPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
            return mCustomOrders.get(position);
        }

        @Override
        public int getCount() {
            return mStrings.length;
        }
    }


}
